﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CarLeasing.Data;
using CarLeasing.Models;

namespace CarLeasing.Forms
{
    public partial class FilterForm : Form
    {
        public FilterForm()
            : this(new string[0], new string[0], new string[0])
        { }

        public FilterForm(string[] origins, string[] types, string[] price)
        {
            InitializeComponent();

            filter_Origin.SetFilter("产地", origins);
            filter_Type.SetFilter("车型", types);
            filter_Price.SetFilter("价格", price);
        }

        public Func<CarInfo, bool> Filter => car =>
            filter_Origin.Filter(car.Origin) &&
            filter_Type.Filter(car.Type) &&
            filter_Price.Filter(car.Price);

        private void button_Cancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void button_OK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }
    }
}
